package com.fenghongzhang.day011;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import java.util.Random;

public class Main3Activity extends AppCompatActivity {
    private Button debug;
    private Button debug2;
    private static final String TAG = "Main3Activity";
    int a ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);


        debug = (Button) findViewById(R.id.debug);
        debug2 = (Button) findViewById(R.id.debug2);

        a = 3;
        
        debug.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int i = new Random().nextInt(20); //0-19
                int b = a+i;
                Log.i(TAG, "计算: "+b);
                Log.i(TAG, "test: ");
                Log.i(TAG, "test: ");
                Log.i(TAG, "test: ");
                if(b > 5){
                    Log.i(TAG, "onClick: 大于5");
                }
                
            }
        });

        debug2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int i = new Random().nextInt(20); //0-19
                int b = a+i;
                Log.i(TAG, "计算: "+b);

                if(b > 5){
                    Log.i(TAG, "onClick: 大于5");
                }

            }
        });

    }

    public void test(){
        Log.i(TAG, "test: ");
        Log.i(TAG, "test: ");
        Log.i(TAG, "test: ");
    }
}
